/*
 * <h3>Title:wheel-parent系统</h3>
 * <p>Copyright (c) 2019, wnfbx@163.com. All rights reserved.</p>
 * @author wnfbx@163.com
 */
package com.wheel.autoconfigure.dynamicdatasource.loadbalancer;

import java.util.List;
import java.util.concurrent.ThreadLocalRandom;

/**
 * <dt>Description:RandomDataSourceLoadBalancer</dt>
 * <dd>随机数据源均衡器</dd>
 *
 * @author wnfbx@163.com
 * @version 1.0 <i>2019/12/16 22:00</i>
 * @since jdk1.7+
 */
public class RandomDataSourceLoadBalancer implements DataSourceLoadBalancer {

    @Override
    public String determine(List<String> dataSourceKeys) {
        return dataSourceKeys.get(ThreadLocalRandom.current().nextInt(dataSourceKeys.size()));
    }
}
